package com.demo.meidianapp.mvp.base.retroft;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

public class JsDownloadInterceptor implements Interceptor {

    private JsDownloadListener downloadListener;

    public JsDownloadInterceptor(JsDownloadListener downloadListener) {
        this.downloadListener = downloadListener;
    }

    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());

        return response.newBuilder().body(new JsResponseBody(response.body(), downloadListener))
                .build();
    }
}